import request from '@/utils/request'

/**
 * 保存预案内容接口
 * @param {*} data 
 * @returns 
 */
export function editPlan(data) {
  return request({
    url: '/pla/base',
    method: data.planId == 0 ? 'post' : 'put',
    data: data
  })
}

export function editPlanDoc(planId, data) {
  return request({
    url: '/pla/base/insertPlaBaseByElement?planId=' + planId,
    method: 'post',
    data: data
  })
}

export function getPlanDoc(planId) {
  return request({
    url: '/pla/base/selectElementsByPlanId/' + planId,
    method: 'get'
  })
}

/**
 * 删除预案内容接口
 * @param {*} data 
 * @returns 
 */
export function delPlan(planId) {
  return request({
    url: '/pla/base/' + planId,
    method: 'delete'
  })
}

/**
 * 保存预案响应级别内容接口
 * @param {*} data 
 * @returns 
 */
export function editResponseLevel(data) {
  return request({
    url: '/pla/level',
    method: 'put',
    data: data
  })
}

/**
 * 编辑预案流程环节接口
 * @param {*} data 
 * @returns 
 */
export function editPlanHandle(data) {
  return request({
    url: '/pla/handle',
    method: data.handleId == 0 ? 'post' : 'put',
    data: data
  })
}

/**
 * 删除预案流程环节接口
 * @param {*} handleId 
 * @returns 
 */
export function delPlanHandle(handleId) {
  return request({
    url: '/pla/handle/' + handleId,
    method: 'delete'
  })
}

/**
 * 修改流程响应级别内容接口
 * @param {*} data 
 * @returns 
 */
export function editHandleLevel(data) {
  return request({
    url: '/pla/HandleLevel',
    method: 'put',
    data: data
  })
}

/**
 * 批量新增流程环节的响应级别数据
 * @param {*} data 
 * @returns 
 */
export function batchAddHandleLevels(data) {
  return request({
    url: '/pla/HandleLevel',
    method: 'post',
    data: data
  })
}

/**
 * 修改流程任务卡接口
 * @param {*} data 
 * @returns 
 */
export function editHandleTask(data) {
  return request({
    url: '/pla/task',
    method: data.taskId == 0 ? 'post' : 'put',
    data: data
  })
}

/**
 * 删除流程任务卡接口
 * @param {*} taskId 
 * @returns 
 */
export function delHandleTask(taskId) {
  return request({
    url: '/pla/task/' + taskId,
    method: 'delete'
  })
}

/**
 * 获取预案信息接口
 * @param {*} planId 
 * @returns 
 */
export function getPlanInfo(planId) {
  return request({
    url: '/pla/base/' + planId,
    method: 'get'
  })
}

/**
 * 获取预案列表接口
 * @param {*} query 
 * @returns 
 */
export function getPlanList(query) {
  return request({
    url: '/pla/base/list',
    method: 'get',
    params: query
  })
}

/**
 * 调整流程环节排序
 * @param {*} data 
 * @returns 
 */
export function editHandleSort(data) {
  return request({
    url: '/pla/handle/updateSort',
    method: 'put',
    data: data
  })
}

/**
 * 复制其他预案的章节内容
 * @param {*} data 
 * @returns 
 */
export function copyNodeFromPlan(planId, elementId) {
  return request({
    url: '/pla/base/copyPlaToNewPla/' + planId + '/' + elementId,
    method: 'post',
    data: null
  })
}